/*
 * Copyright (c) 2015 www.smarthome.com All rights reserved. 本软件源代码版权归----所有,未经许可不得任意复制与传播.
 */
package com.smarthome.base.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.smarthome.base.dao.ShUserResourceDao;
import com.smarthome.base.dao.base.BaseDao;
import com.smarthome.base.service.ShUserResourceService;
import com.smarthome.base.service.base.BaseServiceImpl;
import com.smarthome.domain.bean.ShUserResource;
import com.smarthome.domain.enums.ShUserResourceOpenFlagEnum;

/**
 * ShUserResourceService 实现类
 * @author KongXiangyu
 * @since 2015-09-07
 */
@Service("shUserResourceService")
public class ShUserResourceServiceImpl extends BaseServiceImpl<ShUserResource, Long> implements ShUserResourceService {

    @Resource
    private ShUserResourceDao shUserResourceDao;

    public BaseDao<ShUserResource, Long> getDao() {
        return shUserResourceDao;
    }

    @Override
    public List<ShUserResource> queryUserResourcesByUserId(Long userId) {
        return shUserResourceDao.queryUserResourcesByUserId(userId);
    }

    @Override
    public List<ShUserResource> queryUserResourcesByUserAndRole(Long userId, Long residenceId) {
        return shUserResourceDao.queryUserResourcesByUserAndRole(userId, residenceId);
    }

    @Override
    public List<ShUserResource> queryAllOpenedUserResources() {
        ShUserResource shUserResource = new ShUserResource();
        shUserResource.setOrderField("sort_weight");
        shUserResource.setOrderFieldType("ASC");
        shUserResource.setOpenFlag(ShUserResourceOpenFlagEnum.OPEN.getFlag());
        return selectEntryList(shUserResource);
    }
}